package cc.magicjson.jpa.datasouce.utils;

import io.github.linpeilie.Converter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;

/**
 * Mapstruct 工具类
 */
@Component
public class MapstructUtils {

    @Autowired
    private Converter converter;

    public <T, V> V convert(T source, Class<V> desc) {
        return converter.convert(source, desc);
    }

    public <T, V> V convert(T source, V desc) {
        return converter.convert(source, desc);
    }

    public <T, V> List<V> convert(List<T> sourceList, Class<V> desc) {
        return converter.convert(sourceList, desc);
    }

    public <T> T convert(Map<String, Object> map, Class<T> beanClass) {
        return converter.convert(map, beanClass);
    }
}
